<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>状态修改</title>
</head>
<body>
<script>
  /**
   * 改变对象状态方式:
   *  1.调用resolve函数(成功)或reject函数(失败)
   *  2.throw抛出错误
   */

//resolve改变状态
  let p0=new Promise((resolve,reject)=>{
    resolve()
  })
  console.log(p0)
//reject改变状态
  let p1=new Promise((resolve,reject)=>{
    reject('err')
          }
  )
  p1.catch(
          (err)=>{
            console.log(err)}
  )
  console.log(p1)

//throw改变状态
  let p3=new Promise((resolve,reject)=>{
   throw new Error('错误')
  })
  console.log(p3)

</script>
</body>
</html>